package com.zhuang.chapter14.work04;

import java.util.ArrayList;

public class StudentData implements Data<Student> {

	ArrayList<Student> studentList = new ArrayList<>();

	@Override
	public void add(Student s) {
		studentList.add(s);
	}

	@Override
	public void remove(Student s) {
		studentList.remove(s);
	}

	@Override
	public void update(int index, Student s) {
		for (int i = 0; i < studentList.size(); i++) {
			if (s == studentList.get(i)) {
				index = i;
				break;
			}
		}
		studentList.set(index, s);
	}

	@Override
	public Student query(int index) {
		return studentList.get(index);
	}

	public ArrayList<Student> getArrayList() {
		return this.studentList;
	}
}
